<template>
    <div>
        <el-table
            :data="tableData"
            row-key="id"
            border>
            <el-table-column prop="id" label="ID" width="60"/>
            <el-table-column prop="user.user_name" label="用户名" />
            <el-table-column prop="user.nickname" label="昵称" />
            <el-table-column prop="balace" label="余额" :formatter="$func.tableAmount"/>
            <el-table-column prop="updated_amount" label="变动金额" :formatter="$func.tableAmount"/>
            <el-table-column prop="updated_at" label="变动时间" width="165" :formatter="$func.tableTime"/>
            <el-table-column label="操作" width="166">
                <template #default="scope">
                    <el-button 
                        type="text" 
                        size="small" 
                        icon="Edit" 
                        @click="$refs.listCreate.Open({address:scope.row})" 
                        v-hasPerm="['users:address:update']">编辑</el-button>
                    <el-popconfirm 
                        v-hasPerm="['users:address:delete']" 
                        @confirm="deleteAddress(scope.row)"
                        :title="'确定删除 【' + scope.row.user.user_name + '】 的钱包?'">
                        <template #reference>
                            <el-button type="text" size="small" icon="Delete">删除</el-button>
                        </template>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
export default {
    data(){
        return {
            tableData: [],
            count: 0,
            forms: {
                page: 1,
                limit: 10,
            },
        }
    },
    methods:{
        // 搜索数据
        searchData(res = {}){
            res.page = this.forms.page || 1
            res.limit = this.forms.limit || 10
            this.forms = res
            this.initData()
        },
        // 分页数据加载
        searchPage(res){
            this.forms.page = res.page
            this.forms.limit = res.limit
            this.initData()
        },
        // 初始化数据加载
        initData(){
            var that = this
            that.$http.get("/admin/user/wallet/list",{params: that.forms}).then(res=>{
                that.count = res.total
                that.tableData = res.data
            })
        },
    },
    mounted() {
        this.initData()
    },
}
</script>